<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>JSX</title>
    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <style>
      #header{
        height: 100px;
        background-color: #aef;
      }
      #main{
        height: 400px;
        background-color: rgb(255, 239, 170);
      }
      #footer{
        height: 100px;
        background-color: rgb(226, 153, 204);
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      //声明一个组件 函数式组件  类式组件
      //函数名称首字母一定要大写, 最终的返回结果是『虚拟 DOM 对象』
      function Header(){
        return <div id="header">头部区域</div>
      }

      function Main(){
        return <div id="main">主体区域</div>;
      }

      function Footer(){
        return <div id="footer">底部区域</div>;
      }


      //创建虚拟 DOM 对象
      //react在渲染组件标签时, 会根据标签名,寻找同名的函数, 然后执行该函数, 获得对应虚拟 DOM 结构
      // let vdom = ;
      function App(){
        return <div>
          <Header></Header>
          <Main />
          <Footer/>
        </div>;
      }

      //声明一个虚拟 DOM 对象
      let v1 = <div title="hello text">hello</div>;
      console.log(v1);

      let v2 = <Header />;
      console.log(v2);

      //渲染
      ReactDOM.render(<App />, document.querySelector('#root'))
    </script>
  </body>
</html>
